using System.Text;
using zevenseas.Community.Search;

namespace zevenseas.Community.Search
{
    public class SearchWherePropertyDateAdd : WhereProperty
    {
        private int within;
        private TimeUnits withinTimeUnit;

        public int Within
        {
            get { return within; }
            set { within = value; }
        }

        public TimeUnits WithinTimeUnit
        {
            get { return withinTimeUnit; }
            set { withinTimeUnit = value; }
        }

        public override string ToString()
        {
            StringBuilder dateAddString = new StringBuilder();
            dateAddString.Append(@"(");
            dateAddString.Append(Property);
            dateAddString.Append(@" >=DATEADD(");
            dateAddString.Append(withinTimeUnit.ToString());
            dateAddString.Append(@", -");
            dateAddString.Append(within);
            dateAddString.Append(@", GETGMTDATE()))");

            return dateAddString.ToString();
        }
    }
}